cmake_minimum_required(VERSION 3.10)

project(hello_dds VERSION 1 LANGUAGES CXX)

set(LOGGER_OUTPUT_PATH  ${CMAKE_SOURCE_DIR}/output/logger)
set(DDS_OUTPUT_PATH  ${CMAKE_SOURCE_DIR}/output/fastdds)
# 设置 cmake 默认安装路径
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/output/bin)
set(LIBRARY_OUTPUT_PATH  ${CMAKE_SOURCE_DIR}/output/lib)
#set(CMAKE_NINJA_OUTPUT_PATH_PREFIX  ${CMAKE_SOURCE_DIR}/output/include)

include_directories(
        #[[ 日志相关头文件 ]]
        ./logger/include

        #[[ fastDDS 使用 ]]
        ./fastDDS/include
        #[[ fastDDS 库相关头文件 ]]
        ${DDS_PATH}/include
        ${DDS_PATH}/include/fastdds/thirdparty/optionparser

        #[[ appfw 封装 ]]
        ./appfw/include
        ./appfw/src
        )

file(GLOB COMM_SOURCE_FILES
#        ./main.cpp
        #[[ fastDDS 使用 ]]
        ./fastDDS/source/*.cxx
        ./fastDDS/source/*.cpp
        #[[ 日志相关源文件 ]]
        ./logger/source/*.cpp
        #[[ appfw 封装 ]]
        ./appfw/src/*.cpp
#        ./appfw/src/component/*.cpp
        ./appfw/src/node/*.cpp
        ./appfw/src/transport/*.cpp
#        ./appfw/src/transport/pps/*.cpp
#        ./appfw/src/transport/lcm/*.cpp
#        ./appfw/src/transport/iox/*.cpp
        ./appfw/src/transport/dds/*.cpp
        )

file(GLOB PUBLISHER_FILE
        ./Publisher_main.cpp
        )

file(GLOB SUBSCRIBER_FILE
        ./Subscriber_main.cpp
        )

link_directories(${DDS_PATH}/lib)
#add_executable(${PROJECT_NAME} ${COMM_SOURCE_FILES})
add_executable(publisher_test ${PUBLISHER_FILE} ${COMM_SOURCE_FILES})
add_executable(subscriber_test ${SUBSCRIBER_FILE} ${COMM_SOURCE_FILES})
#[[target_link_libraries(${PROJECT_NAME}
        fastcdr
        foonathan_memory-0.7.3
        fastrtps
        pthread
        )]]

target_link_libraries(publisher_test
        fastcdr
        foonathan_memory-0.7.3
        fastrtps
        pthread
        )
target_link_libraries(subscriber_test
        fastcdr
        foonathan_memory-0.7.3
        fastrtps
        pthread
        )

file(COPY ${CMAKE_SOURCE_DIR}/logger/include DESTINATION ${LOGGER_OUTPUT_PATH})
file(COPY ${DDS_PATH}/lib DESTINATION ${DDS_OUTPUT_PATH})
file(COPY ${DDS_PATH}/include DESTINATION ${DDS_OUTPUT_PATH})
file(COPY ${DDS_PATH}/bin DESTINATION ${DDS_OUTPUT_PATH})
file(COPY ${DDS_PATH}/share DESTINATION ${DDS_OUTPUT_PATH})
file(COPY ${DDS_PATH}/tools DESTINATION ${DDS_OUTPUT_PATH})

